-
Notifications
You must be signed in to change notification settings - Fork 1.2k
design: samconfig #1503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
design: samconfig #1503
Conversation
- an app level configuration that provides parameter pass throughs for sam cli commands
awood45
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some feedback.
designs/sam-app-config.md
Outdated
|
|
||
| * `sam package --s3-bucket ... --template-file ... --output-template-file ... --s3-prefix ... --kms-key-id ...` | ||
|
|
||
| * `sam deploy deploy --template-file ... --stack-name ... --capabilities ... --tags ... --parameter-overrides ... --kms-key-id ...` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sam deploy deploy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
designs/sam-app-config.md
Outdated
| * `sam package` | ||
| * `sam deploy` | ||
|
|
||
| That would be a huge user experience win. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add to the problem some more considerations:
- Dev/Beta/PreProd/Prod workflows may vary and need to be reflected somehow.
- There is a tie-in with
~/.aws/credentialsand~/.aws/configto respect, or at least to keep consistent in some way. - A solution should allow for overriding of any defaults - explicit parameter choices should always be respected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily. ~/.aws/credentials and ~/.aws/config are global files. Yes, explicit parameter will always be respected. I can add that under a section called tenets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are global config files, but do we want the same profile identifier to work for both? Why or why not? Let's make a conscious decision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can always leave the door open for identifiers, but I'd prefer not to start with one. It may conflate expectations with aws profiles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to start with simple, as long as we keep door open to add profiles in future if needed
designs/sam-app-config.md
Outdated
|
|
||
| The suite of commands supported by SAM CLI would be aided by looking for a configuration file thats locally located to the template.yaml by default. | ||
|
|
||
| `.aws-sam/sam-app-config` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an .aws-sam directory relative to the project? Would we want to conflate this with build directories like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, its where build artifacts go today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd want to separate these concepts. I don't think there's any harm to having this expected to exist at project root, or to be otherwise specified. (On that note, we should support an ENV variable for this possibly).
designs/sam-app-config.md
Outdated
|
|
||
| Sample configuration file | ||
|
|
||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INI format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, do we want to consider user profiles in a way that aligns with AWS CLI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is toml. looks similair to ini but understands types better. pip today respects pyproject.toml. I'd rather have multiple configuration files, similar to how parameter overrides usually denote different environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make sure toml supports what we want. I am ok with it but I prefer us to not support multiple configuration files. The upkeep on that might be more than we originally think.
designs/sam-app-config.md
Outdated
| Out-of-Scope | ||
| ------------ | ||
|
|
||
| * Not focusing on a global configuration. SAM CLI already has a notion of a global config at `~/.aws-sam/metadata.json` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different in nature. In the future, could always support a global configuration file in ~/.aws-sam/ - it doesn't conflict with metadata.json existing. It's an intentional choice because a global config may not make sense for this problem.
designs/sam-app-config.md
Outdated
| region="us-east-1" | ||
| profile="srirammv" | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be worth mentioning how this config file will be bootstrapped. By hand? By a helper command? Via init? Some combination?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This design does not cover for that scenario, but can account for potential directions forward.
designs/sam-app-config.md
Outdated
|
|
||
| The suite of commands supported by SAM CLI would be aided by looking for a configuration file thats locally located to the template.yaml by default. | ||
|
|
||
| `.aws-sam/sam-app-config` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why sam-app-config? Should we simplify this further to samconfig?
I am confused on the placement within .aws-sam. To this point, this directory is generated by the cli directly (to ensure correct permissions, mainly). With this, we are suggestion to customers that they need to now create this directory. This might be ok if the entry point was through a command (sam config generate) but we aren't that far yet. Why not place this within the root of the project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move it up to the project root, to me this configuration was very specific to the app the user was working on at that point. Also might prevent accidental checking it in to source control, since we ignore the .aws-sam directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sam-app-config because it doesn't change the inherent behavior of SAM CLI, its a pass through of parameters.
designs/sam-app-config.md
Outdated
|
|
||
| Sample configuration file | ||
|
|
||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make sure toml supports what we want. I am ok with it but I prefer us to not support multiple configuration files. The upkeep on that might be more than we originally think.
designs/sam-app-config.md
Outdated
| CLI Changes | ||
| ----------- | ||
|
|
||
| New command line argument is added per command called `--config` to be able to specify non default locations of config files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we wouldn't want a command to not have the --config option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generate-event consists of tons of subcommands, that may be a place where config might not be used as much. But we can add it across all commands.
designs/sam-app-config.md
Outdated
| What will be changed? | ||
| --------------------- | ||
|
|
||
| The suite of commands supported by SAM CLI would be aided by looking for a configuration file thats locally located to the template.yaml by default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work with build then? We have (at least try to) trained customers to operate on their source. In cases of build, we generate a new template for them (that they shouldn't care about). This means in some cases, we would pick the config in the source but others (that have run build before) we will be looking at the built template. Lets be strong on where this should live, otherwise this can be a point of confusion for customers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to project level with an option to set the location of the configuration file with a environment variable.
designs/sam-app-config.md
Outdated
| Documentation Changes | ||
| ===================== | ||
|
|
||
| * Addition of a new `--config` file parameter per command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about docs page about the config, what it does, how/why you should use it?
|
open to modification of |
sanathkr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome! Very powerful capability. I know we are rushing this quick, but I would like if you can explain all the other ways this feature can be extended in the future such as global + project-level config, checking the config into Git repo, multiple config files with a naming convention, etc.
Also, can you elaborate on how a users can use --debug to understand how SAM CLI read the config?
designs/sam-config.md
Outdated
| ``` | ||
|
|
||
|
|
||
| The default location of a .sam-config can be replaced by overriding an environment variable called `SAM_CONFIG` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this consistent with other env vars names? Should we make this SAM_CLI_CONFIG?
designs/sam-config.md
Outdated
|
|
||
| The suite of commands supported by SAM CLI would be aided by looking for a configuration file thats locally located at the project root where template.yaml is located by default. | ||
|
|
||
| `.sam-app-config` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change?
| ==================================== | ||
|
|
||
|
|
||
| What is the problem? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide a bigger scope
designs/sam-config.md
Outdated
| @@ -0,0 +1,282 @@ | |||
| SAM CLI App Level Config | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call this "SAM Config" in general then?
| Be default the `default` section of the configuration is chosen. | ||
|
|
||
| ``` | ||
| [default] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome!
designs/sam-config.md
Outdated
| region="us-east-1" | ||
| profile="srirammv" | ||
|
|
||
| [dev] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes much more sense to me. I like this
designs/sam-config.md
Outdated
|
|
||
| Users can pass an identifier for the section that will be scanned within the configuration file to pass parameters through. | ||
|
|
||
| Be default the `default` section of the configuration is chosen. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: By default
| skip_pull_image=true | ||
| use_container=true | ||
|
|
||
| [default.package] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not overly familiar with TOML but is this required? What would we place in this section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its to showcase nesting, its theoretically not required, so I'll remove it for brevity.
designs/sam-config.md
Outdated
|
|
||
| * Potentially every sam command could have functionality to have a series of command line parameters exported into a configuraion file. | ||
|
|
||
| Tenets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: consider moving this up before "What will be changed?". Might help set some context and be easier to reference and update when we make changes in the future.
- todo add more scope
2273fc8 to
fc91010
Compare
|
|
||
| Optionally, if multiple configuration files are checked in. One can change the `SAM_CLI_CONFIG` environment variable to point a different configuration file. | ||
|
|
||
| `--env` can also be passed in to deal with custom environments defined in the configuration file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use a different parameter name than this, something more descriptive/connected to the config file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to suggestions.
| * Read `--env` to make sure we can select an appropriate portion in configuration file. | ||
|
|
||
|
|
||
| `.samrc` Changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is samrc. Can you actually rename this part of the design doc template to call it samconfig instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure.
|
|
||
| ` | ||
| sam build --env devo | ||
| Error: Environment 'devo' was not found in .aws-sam/samconfig.toml , Possible environments are : ['dev', 'prod'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job on the thinking ahead about error messages.
designs/sam-config.md
Outdated
| Test Scenarios/Cases | ||
| -------------------- | ||
|
|
||
| * Integration tests for every command with identifer based overrides, and command line overrides on existing sam configuration file and custom configuration file through environment variables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/identifier/env
|
|
||
| N/A | ||
|
|
||
| Test Scenarios/Cases |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you plan to verify that the config file with every single CLI command we have today and in future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add a configuration file version number
| Documentation Changes | ||
| ===================== | ||
|
|
||
| * Addition of a new `--env` parameter per command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need documentation on how to write the config file. How to specify flags like --debug that don't have explicit values. How to verify whether a config file is parsable or not.
* design: sam-app-config - an app level configuration that provides parameter pass throughs for sam cli commands * design: move config file location to project root * design: add open questions * fix: add `identifiers` to use configuration file. * fix: address comments - todo add more scope * fix: address future and scope * phases: implementation phases * fix: add docs section for samconfig
* design: sam-app-config - an app level configuration that provides parameter pass throughs for sam cli commands * design: move config file location to project root * design: add open questions * fix: add `identifiers` to use configuration file. * fix: address comments - todo add more scope * fix: address future and scope * phases: implementation phases * fix: add docs section for samconfig
a configuration that provides parameter pass throughs for
sam cli commands
Write Design Document (Do I need to write a design document?)
Write unit tests
Write/update functional tests
Write/update integration tests
make prpassesWrite documentation
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.